package org.xinghai.sql.main.generator.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;



import org.springframework.stereotype.Service;
import org.xinghai.sql.main.dto.CreateTableDto;
import org.xinghai.sql.main.generator.domain.ColumnElements;
import org.xinghai.sql.main.generator.domain.DatabaseTables;
import org.xinghai.sql.main.generator.domain.TableColumns;
import org.xinghai.sql.main.generator.mapper.DatabaseTablesMapper;
import org.xinghai.sql.main.generator.service.DatabaseTablesService;

import java.util.List;

/**
* @author lijia
* &#064;description  针对表【database_tables】的数据库操作Service实现
* &#064;createDate  2025-07-28 11:43:08
*/
@Service
public class DatabaseTablesServiceImpl extends ServiceImpl<DatabaseTablesMapper, DatabaseTables>
    implements DatabaseTablesService {

    @Override
    public void createTable(CreateTableDto createTableDto) {
        DatabaseTables databaseTables = new DatabaseTables();
        databaseTables.setTableName(createTableDto.getTableName());
        databaseTables.setDatabaseName(createTableDto.getDatabaseName());
        databaseTables.setDescription(createTableDto.getDescription());
        this.save(databaseTables);
    }

    @Override
    public List<TableColumns> getTableColumnsByTableId(Integer tableId) {
        return baseMapper.getTableColumnsByTableId(tableId);
    }
    //根据表名获取表ID
    @Override
    public Integer getTableIdByTableName(String tableName) {
        return baseMapper.getTableIdByTableName(tableName);
    }

    @Override
    public List<DatabaseTables> getTableByDatabaseName(String databaseName) {
        return baseMapper.getTableByDatabaseName(databaseName);
    }

    @Override
    public Integer getTableIdByTableNameFromDatabaseName(String tableName, String databaseName) {
        return baseMapper.getTableIdByTableNameFromDatabaseName(tableName, databaseName);
    }
}




